#include "../logs/log.h"
#include <unistd.h>

void test(const std::string& name){
    INFO("开始测试");
    log::Logger::ptr logger = log::LoggerManager::getInstance().getLogger(name);
    logger->debug("%s", "测试日志");
    logger->info("%s", "测试日志");
    logger->error("%s", "测试日志");
    logger->warn("%s", "测试日志");
    logger->fatal("%s", "测试日志");
    /* size_t count = 0;
    while(count < 100000){
        logger->fatal("测试日志-%d", count++);
    } */
    INFO("结束测试");
}
int main(){
    std::unique_ptr<log::LoggerBuilder> builder(new log::GlobalLoggerBuilder());
    builder->buildLoggerName("sync_logger");
    builder->buildFormatter("[%d{%H:%M:%S}][%c][%f:%l][%p]%T%m%n");
    builder->buildLoggerLevel(log::LogLevel::value::DEBUG);
    builder->buildLoggerType(log::LoggerType::LOGGER_SYNC);
    builder->buildSink<log::StdoutSink>();
    builder->buildSink<log::FileSink>("./logfile/test.log");
    builder->buildSink<log::RollBySizeSink>("./logfile/roll-", 1024 * 1024);
    log::Logger::ptr logger = builder->build();

    test("sync_logger");

    return 0;
}